package com.vlin.config.mybatis;

import javax.sql.DataSource;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import com.alibaba.druid.pool.DruidDataSource;

@Configuration
public class DataSourceConfig {

	@Autowired
	MybatisProperties mybatisProperties;
	
	@Bean
	DataSource dataSource() {
		DruidDataSource dataSource = new DruidDataSource();
		dataSource.setUrl(mybatisProperties.getUrl());
		dataSource.setDriverClassName(mybatisProperties.getDriverClassName());
		dataSource.setName(mybatisProperties.getUsername());
		dataSource.setPassword(mybatisProperties.getPassword());
		return dataSource;
	}
}
